//
//  ZDGoodsScoreCell.m
//  ZDPension
//
//  Created by 刘甲奇 on 2017/6/21.
//  Copyright © 2017年 maker. All rights reserved.
//

#import "ZDGoodsScoreCell.h"

@interface ZDGoodsScoreCell()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UIButton *starButton1;
@property (weak, nonatomic) IBOutlet UIButton *starButton2;
@property (weak, nonatomic) IBOutlet UIButton *starButton3;
@property (weak, nonatomic) IBOutlet UIButton *starButton4;
@property (weak, nonatomic) IBOutlet UIButton *starButton5;
/**
 <#Description#>
 */
@property(nonatomic, strong) goodsScoreBlock block;

@end

@implementation ZDGoodsScoreCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.textView.layer.borderColor = LEHaxColor(0xe8e8e8).CGColor;
    self.textView.layer.borderWidth = 1;
    self.textView.textColor = LEHaxColor(0x808080);
    self.textView.delegate = self;
}

- (void)setDetailModel:(ZDGoodsDetailModel *)detailModel
{
    _detailModel = detailModel;
    self.titleLabel.text = detailModel.goods_name;
    
}
- (IBAction)starClick1:(UIButton *)sender
{
    [self.starButton1 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton2 setImage:[UIImage imageNamed:@"b"] forState:0];
    [self.starButton3 setImage:[UIImage imageNamed:@"b"] forState:0];
    [self.starButton4 setImage:[UIImage imageNamed:@"b"] forState:0];
    [self.starButton5 setImage:[UIImage imageNamed:@"b"] forState:0];
    _detailModel.score = @"1";
    _block(_detailModel);
}
- (IBAction)starClick2:(UIButton *)sender
{
    [self.starButton1 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton2 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton3 setImage:[UIImage imageNamed:@"b"] forState:0];
    [self.starButton4 setImage:[UIImage imageNamed:@"b"] forState:0];
    [self.starButton5 setImage:[UIImage imageNamed:@"b"] forState:0];
    _detailModel.score = @"2";
    _block(_detailModel);
}
- (IBAction)starClick3:(UIButton *)sender
{
    [self.starButton1 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton2 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton3 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton4 setImage:[UIImage imageNamed:@"b"] forState:0];
    [self.starButton5 setImage:[UIImage imageNamed:@"b"] forState:0];
    _detailModel.score = @"3";
    _block(_detailModel);
}
- (IBAction)starClick4:(UIButton *)sender
{
    [self.starButton1 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton2 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton3 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton4 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton5 setImage:[UIImage imageNamed:@"b"] forState:0];
    _detailModel.score = @"4";
    _block(_detailModel);
}
- (IBAction)starClick5:(UIButton *)sender
{
    [self.starButton1 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton2 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton3 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton4 setImage:[UIImage imageNamed:@"a"] forState:0];
    [self.starButton5 setImage:[UIImage imageNamed:@"a"] forState:0];
    _detailModel.score = @"5";
    _block(_detailModel);

}
- (void)goodsScoreClick:(goodsScoreBlock)block
{
    _block = block;
}
#pragma mark-UITextViewDelegate
- (void)textViewDidEndEditing:(UITextView *)textView
{
    _detailModel.commitContent = textView.text;
}

@end
